package com.itheima.health.mapper;

import com.itheima.health.dto.StatisticsMemberDTO;
import com.itheima.health.dto.StatisticsOrderDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;

@Mapper
public interface ReportMapper {
    @Insert("insert into statistics_members(date, new_count, all_count) VALUE (#{date}, #{newCount}, #{allCount})")
    void insertMemberStatistics(StatisticsMemberDTO dto);

    @Insert("insert into statistics_order(date, appointment_count, visit_count) VALUE (#{date}, #{appointmentCount}, #{visitCount})")
    void insertOrderStatistics(StatisticsOrderDTO dto1);

    @Select("select all_count from statistics_members where date = #{endOfMonth}")
    Integer getMemberTotalCountByMonth(LocalDate endOfMonth);

    @Delete("delete from statistics_members where date = #{date}")
    void deleteMemberStatisticsByDate(LocalDate date);

    @Delete("delete from statistics_order where date = #{date}")
    void deleteOrderStatisticsByDate(LocalDate date);
}
